/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Base;

/**
 *
 * @author Usuario
 */

import Negocio.MailEnvio;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class MailDB {
	

	public boolean ingresoMail (MailEnvio mail,int id_servidor) throws SQLException
	{		
		DatabaseManager db = new DatabaseManager();
                Connection var = db.getConnection();
		Statement stmt = var.createStatement();
                boolean resultado=stmt.execute("INSERT INTO EMAIL VALUES(INCREMENTO_MAIL.NEXTVAL,'"+mail.getAsunto()+"','"+mail.getCuerpo()+"','"+mail.getFecha()+"')" );
                stmt.execute("INSERT INTO RECIBIDO VALUES(INCREMENTO_MAIL.CURRVAL,'"+mail.getRemitente()+"')" );
                stmt.execute("INSERT INTO ESTADO VALUES(1,INCREMENTO_MAIL.CURRVAL)" );
                stmt.execute("INSERT INTO SERVIDOR_RECIBIDO VALUES (INCREMENTO_MAIL.CURRVAL,"+id_servidor+")");
                var.commit();
                db.getConnection().close();
		return resultado;
	}
	 
    
        
}

